<?php

namespace Part01_SimpleFactoryMode\Code4;

require_once '../../autoload.php';

$numA = $_POST['numA'];
$operate = $_POST['operate'];
$numB = $_POST['numB'];
if (!$numA || !$numB || !$operate) {
    echo '缺少必要参数';
    die;
}
$opeObj = OperationFactory::createOperate($operate);
$opeObj->setNumA($numA);
$opeObj->setNumB($numB);
try {
    $result = $opeObj->getResult();
    echo "结果是" . $result;
} catch (Exception $e) {
    echo 'catch 异常：' . $e->getMessage();
}